home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / Apple Script / OSAX / Four Password OSAXen / PassWord4 Folder / PassWord4.c < prev    next >
C/C++ Source or Header  |  1993-05-14  |  2KB  |  61 lines

  1. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. //    Password4.c
  4. //    Written by: Donald Olson
  5. //    May 1993
  6. //    Copyright ® 1993 Apple Computer Inc.
  7. //     All rights reserved.
  8. //
  9. //    This is a simple Scripting Addition that clears a password that
  10. //    has been stored in the User PassWord3 or User PassWord2 scripting
  11. //    addition. This was written for a talk at the 1993 WWDC given
  12. //     by Donald Olson and Donn Denman.
  13. //
  14. //    Syntax: Clear Password
  15. //    Return: None.
  16. //
  17. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  18.  
  19. #include <string.h>
  20. #include <Dialogs.h>
  21. #include <AppleEvents.h>
  22. #include <Memory.h>
  23.  
  24. // Our constants
  25. #define MYClass     'OLIE'
  26. #define MyID        'psw3'
  27. #define MyID2    'psw2'
  28.  
  29. pascal OSErr main(AppleEvent *theEvent, 
  30.                 AppleEvent *theReply, 
  31.                 long theRefCon) {
  32.  
  33.     OSErr                theErr = noErr;
  34.     EventHandlerProcPtr    handler;
  35.     long                    handlerRefcon = 0;    
  36.     DescType            theID = MyID;
  37.     
  38.     theErr = AEGetEventHandler(MYClass, theID, 
  39.                             &handler, &handlerRefcon, true);
  40.     if(theErr != noErr) {
  41.         /*
  42.             Maybe it was installed with the first of our osaxes,
  43.             try again with its ID
  44.         */
  45.         
  46.         theID = MyID2;
  47.         theErr = AEGetEventHandler(MYClass, theID, 
  48.                             &handler, &handlerRefcon, true);
  49.         if(theErr != noErr) return theErr;                    
  50.     }
  51.     
  52.     if(handlerRefcon != 0)
  53.         DisposeHandle((Handle)handlerRefcon);    // Get rid of our handle
  54.         
  55.     theErr = AEInstallEventHandler(MYClass, theID, 
  56.                                 handler, 0, true);
  57.         
  58.     return theErr;
  59. }
  60.  
  61.